﻿using First.BLL;
using First.DAL;
using First.Model;
using Microsoft.AspNetCore.Mvc;

namespace First.Controllers
{
    public class StudentController : Controller
    {
        StudentDAL studentdal = new StudentDAL();
        StudentBLL studentbll = new StudentBLL();
        /// <summary>
        /// Index
        /// </summary>
        /// <returns></returns>
        public IActionResult Index()
        {
            return View();
        }
        /// <summary>
        /// 获取所有学生的详细信息
        /// </summary>
        /// <returns></returns>
        public IActionResult Get()
        {
            return Json(studentbll.GetJsonStudentDetail());
        }

        /// <summary>
        /// 删除学生信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult Del(int id)
        {
            return Json(studentbll.DelJsonStudent(id));
        }

        /// <summary>
        /// 增加、修改学生信息
        /// </summary>
        /// <param name="student"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult Edit(Student student)
        {
            return Json(studentbll.EditJsonStudent(student));
        }
    }
}